<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<title>航空智造数据融合系统</title>
	<script src="${ctx}/common/plateform/base/jquery/jquery.min.js"></script>
	<script src="${ctx}/common/plateform/base/bootstrap/bootstrap.min.js"></script>
	<link href="${ctx}/common/plateform/base/bootstrap/bootstrap.min.css" rel="stylesheet">
	<link href="${ctx}/common/plateform/plugins/adminlte/AdminLTE.css" rel="stylesheet">
	<script src="${ctx}/common/plateform/base/layer/layer.js"></script>
	<link href="${ctx}/common/plateform/base/fonts/font-awesome.min.css" rel="stylesheet">
	<link href="${ctx}/common/plateform/base/utils/plateform.css" rel="stylesheet" />
	<link href="${ctx}/common/plateform/base/utils/mystyle.css" rel="stylesheet" />
	<script src="${ctx}/common/plateform/base/utils/jquery-md5-min.js"></script>
	<!--[if gte IE 6]>
	<script src="${ctx}/common/plateform/plugins/ie/html5shiv.min.js"></script>
	<script src="${ctx}/common/plateform/plugins/ie/respond.js"></script>
	<![endif]-->
	<script>
		var ctx = '${ctx}';
	</script>
	<script type="text/javascript">
		function viewVerifyCode() {
			var r = "";
			if (undefined != ctx)
				r = ctx;
			document.getElementById("verifyCode").style.visibility = "visible";
			document.getElementById("verifyCode").src = ctx + "/web/CheckRandCode?" + Math.random();
		}
	</script>
</head>
<style>
	.login_wrap {
		background: url("${ctx}/images/plateform/login_bg_plateform2.jpg") no-repeat;
		background-size: 100%;
		margin-top: 10px;
	}
</style>

<body>
<div class="container">
	<h1 class="login_title">
		<div class="col-lg-12" style="display:flex;justify-items:start;">
			<img class="img-responsive" src="${ctx}/images/logo1.png" style="height:63px;">
			<p style="padding-top: 19px;border-right: 0px;color: #0081cc;">航空智造数据融合系统（DFS）</p>
		</div>
	</h1>
</div>
<div class="login_wrap">
	<div class="container">
		<div class="row">
			<div class="col-md-8"></div>
			<div class="col-md-4">

				<!-- login start -->
				<div class="login-box">
					<h6>用户登录</h6>
					<form action="javascript:;" method="post" id="inputForm" name="inputForm" class="inputForm">
						<input id="password_form" name="password" type="hidden" />
						<input id="randCode_form" name="rand" type="hidden" />
						<input id="username_form" name="username" type="hidden" />
						<div class="form-group has-feedback">
							<input id="userEname" class="form-control" tabindex="1"
								   placeholder="输入登录用户名" type="text" value="dxp_admin" maxlength="30"/> <span
								class="fa fa-user form-control-feedback"></span>
						</div>
						<div class="form-group has-feedback">
							<input type="password" id="upass" tabindex="2" class="form-control fft"
								   placeholder="输入登录密码" value="dxp_admin" maxlength="30"> <span
								class="fa fa-lock form-control-feedback"></span>
						</div>

						<div class="form-group has-feedback">
							<input id="rand" size="4" tabindex="3" style="width:50%; margin-right:5px;"
								   class="form-control" placeholder="输入验证码" maxlength="6"> <input name="flagDiv"
																								  id="flagDiv" type="hidden" value="" />
							<img border="0" id="verifyCode" src="" onclick="viewVerifyCode();" align="absmiddle" />
							<script>
								viewVerifyCode();
							</script>
							<span class="fa fa-pencil form-control-feedback"></span>
						</div>
					</form>
					<div class="tools">
						<div id="error-message" class="col-xs-6 col-sm-7 msg"></div>
					</div>
					<div class="login_btn">
						<div class="text-center">
							<button id="btn-login" type="button" class="btn btn-block btn-primary f16" onclick="sumbit()">登 录</button>
						</div>
					</div>
					<!-- /.login-box-body -->
					<!-- login end -->

				</div>
			</div>
		</div>
	</div>
</div>
<!-- foot start -->
<center>
	<footer class="login-footer text-center" style="margin-top:10px; margin-bottom:10px;">
		<p class="col-sm-12 ">版权所有 &copy; 中国航空规划设计研究总院有限公司</p>
	</footer>
</center>
<!-- foot start -->

</body>

<script type="text/javascript">
	//解决ie不支持trim
	$(document).ready(
			function(){
				$("#userEname").focus();
				if(!String.prototype.trim) {
					String.prototype.trim = function () {
						return this.replace(/^\s+|\s+$/g,'');
					};
				}
			}
	);
	//回车登录
	document.onkeydown=function mykeyDown(e){
		//compatible IE and firefox because there is not event in firefox
		e = e || window.event;//兼容IE8
		if(e.keyCode == 13) {sumbit();}
		return;
	};
	//登录操作
	function sumbit(){
		var uname = $('#userEname').val();
		var upass = $('#upass').val();
		if(uname==null|| uname==""){
			setErrMsg('请输入用户名');
			$('#userEname').focus();
			return;
		}
		if(upass==null|| upass==""){
			setErrMsg('请输入密码');
			$('#upass').focus();
			return;
		}
		var index_load = layer.load(1, {shade: false});
		$("#password_form").val(upass.md5());
		$("#randCode_form").val($("#rand").val());
		$("#username_form").val(uname);
		var formUrl =ctx+"/res/login";
		//数据提交
		$.ajax({
			url:formUrl,
			type:'post',
			data: $("#inputForm").serialize(),
			success:function(data){
				console.log(data);
				var jdata = jQuery.parseJSON(data);
				if (jdata.flag == 'T') {
					//使用此种方式防止外部系统登录无法跨域访问
					window.location.href="${ctx}/sendPage/dxp/admin/index";
				} else {
					setErrMsg(jdata.msg);
					clearForm();
				}
				layer.close(index_load);
			},error:function(data){
				layer.close(index_load);
				setErrMsg('与服务器连接失败');
			}
		});
	}

	//清空表单数据
	function clearForm(){
		$("#upass").val("");
		$("#userEname").val("");
	}

	function setErrMsg(msg){
		$("#error-message").html("<font color='red'>"+msg+"</font>");
	}
</script>
</html>

